6. SED the Editor SED and Overview SED is a text editor implemented in Forth, with cursor movement key sequences similar to WordStar. Glossary of Editor Operations Copying Lines F3 & F5 Lines can be copied from one place in a file to another, with the Mark-F3, and Copy Line-F5 commands. Move to the first line of the block of text you wish to copy, and Mark the start of the copy with Mark-F3, now move to the place where you want to copy the text to, and press Copy-F5 once for each line you want to copy. Delete and Un-Delete lines Control-Y & Alt-Y Lines can be deleted with Ctrl-Y, and un-deleted with Alt-Y. Any lines which are deleted are saved in a line delete buffer which currently has room for 50 lines. This is also the number of line deletes which can be un-deleted. Exporting a block of Text Alt-X and Shift Alt-X SED can export lines of text to another file. With Alt-X, first go to the first line of text you want to export, and press F3 mark to mark the start of the block export. Then move to the last line of text you want to export, and press Alt-X. This will cause all of the lines between and including the start and end line to be written out to the file TEMP.SEQ. To specify a different filename to export to, press Shift-Alt-X, instead of Alt-X, and you will be prompted for a name to write to. See also "Importing a File". Exporting to another file Alt-W The current edit file can be written out to another file. By pressing Alt-W, you will be asked for the name of the file to write out to. The entire file contents in memory will be written out to the new filename. If you want to export a small amount of text to another file, you can use the Alt-X Export function. HELP, on line F1 Press F1 for on-line help on the various commands available. Importing a File Alt-V Text which has been exported with the Alt-X (export) command to the TEMP.SEQ file can be imported with Alt-V, the import command. If you want to import a file other than TEMP.SEQ, you can press Shift-Alt-V, and a window will pop-up for you to select a file from. If you press Esc during the import, or while in the file selection window, the import operation will be aborted. See also "Exporting a block of Text". Inserting Special characters in SED Alt-C char The Alt-C function allows any single character which can be generated by the keyboard to be inserted into SED. Simply press Alt-C followed by the key you want to insert. Function keys are mapped to characters above 127, so they will show up as graphics characters. Left Margin Ctrl-L The left margin on the screen defaults to column zero, but when printed, defaults to 2 spaces, so it is not normally necessary to insert a left margin. However, when TAB is pressed, the left margin on screen is expanded by 8 characters. Any subsequent lines typed in will maintain this margin. The left margin can be set at any column position. Move the cursor to the column where you want the left margin set and press Ctrl-L. MACROS and FF Alt-M, Alt-1..5 SED does not have macros built into it, but a file is provided called MACROS.SEQ, which implements macros in Forth that can be used in SED. These macros work exactly the same as they work in ZED. That is, you use Alt-M to start defining a macro, followed by one of the Alt-1 to Alt-5 keys for the macro you are defining. Next you enter any keys you want included in the macro, and finally press Alt-M again to complete the macro definition. To perform a macro, simply press one of the Alt-1 through Alt-5 keys by it self, and the keys saved will be performed. Marker, Page Break (a down pointing arrow head) The down pointing arrow head symbol is used by SED to mark the first line of a NEW page, so you will notice this symbol appears at the left edge of the screen at the top of the document. Marker, End of File (an up pointing arrow head) The up pointing arrow head symbol is used by SED to mark the last line of text in the file. Printing Documents Alt-P Printing can be initiated Alt-P. It will take you to a screen where you can set the printing parameters, like first and last page to print, copies to print, etc. These values default to the most common situation, which is to print all of a document once. To start printing, press "P", or press ESC to abort. Reading Foreign documents Alt-K Tab expansion If you want to read a text file from an editor which imbeds Tabs, you will see this character " " in many places in the file when you first start editing it. If you do see these Tab characters, press Alt-K, and these characters will be expanded to spaces properly. This process will increase the size of the file somewhat, so if you are doing this to a very large file, you may run out of the 64000 character memory space available. WordStar document files will need to passed through a conversion utility before being edited by SED. You can import a Forth BLOCK file by specifying the file and extension on the file prompt line. SED will not find any line feeds in the file, so it will automatically split the file at 64 characters per line After this is done, trailing blanks will be stripped from each line, and trailing blank lines will be removed from the file. The resulting file will be much smaller, typically 50 percent or less. The original file is not modified, and the new file is created with the extension ".TMP". Replacing Text F8-Replace & Alt-F8 After a Search has been done, you can replace the text found. Press F8. You will be asked for a replacement string, which will be used to replace the found text, when return is pressed. To search for the next occurrence of the same text, press Alt-F6, and to replace the next found occurrence with the same replacement text, press Alt-F8. Replacing All Occurrences of Text Shift-F8 Having already performed a Search (F6) and Replace (F8) once, you can replace all occurrences of search text with replacement text by pressing Shift-F8. Searching for Text F6-Search & Alt-F6 You can look for any sequence of characters in SED with the Search-F6 key. When F6 is pressed, you are asked to enter a text string to look for. SED will look for that string of characters when you press . When SED searches for text, it ignores the case of the letters. If you want SED to look at the CaSe of the text it searches, hold down SHIFT while pressing . This search is much faster. To search for another occurrence of the same text string, press Alt-F6 (or SHIFT Alt-F6 if you want only an exact match). See also the earlier section on Replacing Text. Searching for Text Backwards Shift-F6 Having already done a search using F6 above, you can also search backwards with Shift-F6, which searches backwards from the cursor with a CaSe sensitive search. Selecting a File to Edit A new file selection mechanism has been added. When you are being asked to enter a new filename, if you press ENTER without entering a filename, a window will pop up allowing you to select a file from the directory. If you are in a sub-directory when the window appears, then a file named "." and a file named ".." will appear at the top of the file list. These files, along with any directories below the current directory, will display a graphic "infinity" symbol "ì" to the right of the filename. If you press while positioned on the "." name you will select the ROOT directory. The ".." name will pop up one level of directory, and any other name with the "infinity" symbol next to it will step you down one level to that directory. You can move between files in the list, with the keypad arrow keys, and select a file by pressing ENTER. Escape can be used to abort file selection. While in the pop up file selection mode, you can also set the current drive by pressing a letter key between A and G. This drive must exist and have a disk in it, or a system error will result. The path and the current drive is displayed in the lower right. The path can be changed by pressing the "\" key, then typing the new path followed by the return key. A filename can be specified on the command line when starting SED, and may include a directory specification. Status Line The top line of the display shows the current edit status, starting with INSERT/OVERWRITE status, which is also shown by a thicker cursor for insert mode. The current Column and Line number are then displayed, followed by the page number, total lines in file and total characters in file. Tab setting Alt-T Set the TAB key to tab to the current column, if you are on column 4, TABS will occur at column 4, 8, 12, 16, etc. Wordstar key functions SED tries somewhat half heartedly to be WordStar compatible. The cursor movement keys, Control A,S,D,F,E,X,C,R,W and Z have been maintained, as have the delete keys Control G,T,Y, and Del. Key Definition Index Control keys A Previous word. B .. C Next page, Page Down. D Right one character. E Previous line, Up Line. F Forward, Next word. G Delete the character UNDER the cursor. H Move left one character non-destructively. I Same as TAB. J .. K .. L .. M Like the key. N Split line at cursor. See also Alt-N (join line). O .. P .. Q .. R Previous page, Page Up. S Left one character. T Delete the word to the right. U Update, save changes up to this moment. V Insert/ Overwrite mode toggle. W Scroll screen down. X Next line, Down Line. Y Cut/Delete the current Line. Z Scroll the screen up. Keypad Functions ESC Exit SED and Save changes. Shift-ESC Exit SED and Don't save changes. Home Goto beginning of line. End Goto end of line. PgUp Go back towards beginning of document 12 lines. PgDn Go towards end of document 12 lines. Ctrl-Home Go to First line of document. Ctrl-End Goto last line of document. Ins Toggle between Insert and Overwrite mode. Del Delete the character under the cursor. Alternate Keys A .. B .. C Insert the next key pressed into the document. D .. E .. F .. G .. H .. I .. J .. K Expand imbedded TAB characters to spaces. L .. M .. N Join Lines, the inverse of Control N. O .. P .. Q .. R .. S .. T Set the TAB key to expand to the current column. U Word Undelete, undeletes the last 10 words or so. V Import a file, pops up a selection window. W Write entire file to a new file. X Export lines from mark to cursor. Y Un-delete lines. Z .. Function Keys F1 .. F2 .. F3 Mark line, for copy lines, and export lines. F4 .. F5 Get a line from the mark. F6 Search, prompts for search text. F7 .. F8 Replace, prompts for replace text, must do F6 first. F9 .. F10 .. Alt-F1 .. Alt-F2 .. Alt-F3 .. Alt-F4 .. Alt-F5 .. Alt-F6 Search for same text again, no prompt. Alt-F7 .. Alt-F8 Replace with same text again, no prompt and do Alt-F6. Alt-F9 .. Alt-F10 .. Shift-F6 Search for text backwards, CaSe sensitive. Shift-F8 Replace all occurrences, use after F6 and F8. Shift-Alt-F6 Search for same text again, no prompt Case Sensitive. Shift-Alt-F8 Replace with same text again, no prompt Case Sensitive. NOTES on F6 and F8 The straight key, F6 or F8 will perform the specified operation, with a prompt for a text string parameter. The operation is performed with a case insensitive search. That is, "CaSe" is the same as "case". The Alt-F6 or Alt-F8 performs the same function, but with the same text string as was entered with the non-Alt key. Again, the search is case insensitive. Holding down Shift while pressing return on F6, Alt-F6 or Alt-F8 will cause the search to be done CASE SENSITIVE. That is, "CaSe" is NOT the same as "case". And finally, pressing Shift-F8, WITHOUT ALT, causes a global replace all occurrences to be performed. While the above may seem confusing at first, it provides a lot of flexibility and power for search and replace operations. Try these commands on a junk file until you become familiar with their operation.